/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */

/*
 * FormUtama.java
 *
 * Created on Jan 3, 2012, 11:50:06 PM
 */
package pkl51.view;

import java.awt.CardLayout;
import javax.swing.JFrame;
import pkl51.controller.CardLayoutController;

/**
 * Menggunakan Singleton Pattern untuk get Form ini. 
 * Singleton Pattern hanya mengijinkan suatu class mempunyai satu objek.
 * Ketika kita butuh form ini tinggal panggil method getInstance.
 * @author ERI
 */
public class FormUtama extends usu.widget.Form {
    
    private CardLayoutController cardControllerUtama;
    private static FormUtama instance;

    public static FormUtama getInstance() {
        if (instance == null || !instance.isVisible()) {
            instance = new FormUtama();
        }
        return instance;
    }

    /** Creates new form FormUtama */
    private FormUtama() {
        this.setTitle("DATA ENTRY PKL 51");
//        this.setUndecorated(true);
        
        initComponents();
        
        setLocationRelativeTo(null);
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        cardControllerUtama = new CardLayoutController();
        cardControllerUtama.setCardLayout((CardLayout) panelBody.getLayout());
        cardControllerUtama.setParentCard(panelBody);
        setCardControllerUtama(cardControllerUtama);
    }

    public CardLayoutController getCardControllerUtama() {
        return cardControllerUtama;
    }

    private void setCardControllerUtama(CardLayoutController cardControllerUtama) {
        this.cardControllerUtama = cardControllerUtama;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelBackground = new pkl51.component.PanelGradient();
        panelHeader = new pkl51.component.PanelTransparan();
        panelBody = new pkl51.component.PanelTransparan();
        panelTransparan = new pkl51.component.PanelTransparan();
        panelLogin = new pkl51.view.PanelLogin();
        panelHome2 = new pkl51.view.PanelHome();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        panelBackground.setMaximumSize(new java.awt.Dimension(1366, 768));
        panelBackground.setPreferredSize(new java.awt.Dimension(1024, 729));

        panelHeader.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));
        panelHeader.setGambar(true);
        panelHeader.setPreferredSize(new java.awt.Dimension(983, 103));

        javax.swing.GroupLayout panelHeaderLayout = new javax.swing.GroupLayout(panelHeader);
        panelHeader.setLayout(panelHeaderLayout);
        panelHeaderLayout.setHorizontalGroup(
            panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 995, Short.MAX_VALUE)
        );
        panelHeaderLayout.setVerticalGroup(
            panelHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 97, Short.MAX_VALUE)
        );

        panelBody.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));
        panelBody.setPreferredSize(new java.awt.Dimension(983, 546));
        panelBody.setLayout(new java.awt.CardLayout());

        panelTransparan.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));

        panelLogin.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));

        javax.swing.GroupLayout panelTransparanLayout = new javax.swing.GroupLayout(panelTransparan);
        panelTransparan.setLayout(panelTransparanLayout);
        panelTransparanLayout.setHorizontalGroup(
            panelTransparanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTransparanLayout.createSequentialGroup()
                .addGap(0, 214, Short.MAX_VALUE)
                .addComponent(panelLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 205, Short.MAX_VALUE))
        );
        panelTransparanLayout.setVerticalGroup(
            panelTransparanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTransparanLayout.createSequentialGroup()
                .addGap(0, 178, Short.MAX_VALUE)
                .addComponent(panelLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 176, Short.MAX_VALUE))
        );

        panelBody.add(panelTransparan, "cardLogin");
        panelBody.add(panelHome2, "card3");

        javax.swing.GroupLayout panelBackgroundLayout = new javax.swing.GroupLayout(panelBackground);
        panelBackground.setLayout(panelBackgroundLayout);
        panelBackgroundLayout.setHorizontalGroup(
            panelBackgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBackgroundLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelBackgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(panelBody, javax.swing.GroupLayout.Alignment.LEADING, 0, 1001, Short.MAX_VALUE)
                    .addComponent(panelHeader, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 1001, Short.MAX_VALUE))
                .addGap(11, 11, 11))
        );
        panelBackgroundLayout.setVerticalGroup(
            panelBackgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBackgroundLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelBody, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelBackground, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelBackground, javax.swing.GroupLayout.DEFAULT_SIZE, 735, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        
        //jika pake mysql portable, uncomment code di bawah ini
//        Thread threadShutdown = new Thread(new ShudownServer());
//        threadShutdown.start();
    }//GEN-LAST:event_formWindowClosing
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private pkl51.component.PanelGradient panelBackground;
    private pkl51.component.PanelTransparan panelBody;
    private pkl51.component.PanelTransparan panelHeader;
    private pkl51.view.PanelHome panelHome2;
    private pkl51.view.PanelLogin panelLogin;
    private pkl51.component.PanelTransparan panelTransparan;
    // End of variables declaration//GEN-END:variables
}
